import POINTLOADING from '@/assets/image/pointloading.gif';
import yuanwen from '@/assets/image/yuanwenicon.png';
import {
  articleRecommend,
  feedback_reasons,
  rewriteSentence,
  search_feedback,
} from '@/services/ant-design-pro/conversation';
import {
  freeReference,
  mainPointGenerate,
  viewpoints,
} from '@/services/ant-design-pro/highClassWrite';
import { AILogsCon } from '@/services/models/dataDoc';
import { replaceN } from '@/utils/index';
import {
  DislikeFilled,
  FilePdfOutlined,
  FileTextOutlined,
  FileUnknownOutlined,
  FileWordOutlined,
  LikeFilled,
} from '@ant-design/icons';
import { Button, Dropdown, message } from 'antd';
import { nanoid } from 'nanoid';
import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
import { connect } from 'umi';
import AnalyzeResult from './com/AnalyzeResult'; //用户文案
import ArticleSource from './com/ArticleSource'; //文章来源
import ContentRich from './com/ContentRich'; //内容丰富提示框
import MarkerProfile from './com/MarkerProfile'; //标记参考内容
import MiniModelArticle from './com/MiniModelArticle'; //小模型文章来源
import RewriteResult from './com/RewriteResult';
import SelectArticleNum from './com/SelectArticleNum'; //用户文案
import ThinkingResult from './com/ThinkingResult'; //思路观点结果
import Typewriter from './com/Typewriter'; //打字机
import UpdateMain from './com/UpdateMain'; //更新大纲
import UserRecover from './com/UserRecover'; //用户文案
const AiCommandLogs: React.FC<any> = forwardRef((props: any, ref) => {
  const { aiLogs, setAILogs, scrollToBottom, scrollToEle, highClassHandle } = props;
  //存储在页面model的数据
  const { curOperationType, writing_session_id } = props.highClassWrite;
  const [feedbackReasons, setFeedbackReasons] = useState<any[]>([]); //点踩反馈文案列表
  //公共更新model的方法
  const updateState = (updateObj: any) => {
    props.dispatch({
      type: 'highClassWrite/updateState',
      payload: updateObj,
    });
  };

  //调用仿写重写的接口 data的数据来源有2个 1个是直接点击点赞弹窗的仿写重写 另外一个是点击右侧的重写仿写按钮
  const handleFanGai = async (type: number, data: any) => {
    let fantxt = '这句话写得不错，多仿写几句';
    let gaitxt = '这句话写得不好，需要重写';
    let reason = type === 1 ? fantxt : gaitxt;
    //发送仿写重写的用户 默认文案
    let userRecover = {
      key: nanoid(),
      type: 'userFanGai',
      data: {
        reason,
        text: data?.text,
        range: data?.range ? data?.range : data,
      },
    };
    setAILogs((prev: any) => [...prev, userRecover]);

    setTimeout(() => {
      let systemTxtRecover = {
        key: nanoid(),
        type: 'systemTxtRecover',
        spend: 30,
        data: [`好的，以下是${type === 1 ? '仿写' : '重写'}的内容`],
      };
      setAILogs((prev: any) => [...prev, systemTxtRecover]);
      updateState({
        robotLoading: true,
      });
    }, 500);

    let body = {
      query: data?.text,
      write_type: type,
    };
    const res = await rewriteSentence(body);
    if (res.code === 0) {
      setTimeout(() => {
        updateState({
          robotLoading: false,
          curOperationType: { type: 'input', data: null },
        });
        let rewriteResult = {
          key: nanoid(),
          type: 'rewriteResult',
          data: res.data,
        };
        setAILogs((prev: any) => [...prev, rewriteResult]);
      }, 1000);
    } else {
      updateState({
        robotLoading: false,
        curOperationType: { type: 'input', data: null },
      });
      message.open({
        type: 'error',
        content: res.msg,
      });
    }
  };
  //获取点踩的反馈列表
  const getFeedbackReasons = async () => {
    let res = await feedback_reasons({});
    if (res.code === 0) {
      setFeedbackReasons(res.data);
    } else {
      message.error(res.msg);
    }
  };
  useEffect(() => {
    getFeedbackReasons(); //获取点踩的反馈列表
  }, []);
  //监听左侧文章组件点赞 点踩 评分的操作
  useEffect(() => {
    if (curOperationType.type === 'fanxie') {
      handleFanGai(1, curOperationType.data);
    }
    if (curOperationType.type === 'gaixie') {
      handleFanGai(2, curOperationType.data);
    }
  }, [curOperationType]);
  //机器人自动回复文案
  useEffect(() => {
    // aiLogs类型
    // 用户输入的指令
    // 通用文字回应
    // 点赞点踩
    // 仿写重写
    // 聊天
    // 机器人loading
    if (aiLogs && aiLogs.length > 0) {
      //aiLogs 判断数组的最后一个的类型 做对应的回复
      let lastLog = aiLogs[aiLogs.length - 1] || null;
      //点赞点踩
      if (lastLog.type === 'userZanCai' && !!lastLog?.data?.range) {
        let zanTxt = '小麦已经收到您的赞！这么棒的文案，需要为您多些几句吗？';
        let caiTxt = '小麦已经收到您的踩！是否需要小麦重新生成几句，来替换不满意的文案？';
        const { type } = lastLog.data;
        let reason = type === 1 ? zanTxt : caiTxt;
        let rewriteTip = {
          key: nanoid(),
          type: 'rewriteTip',
          data: {
            type: type,
            reason: reason,
            text: lastLog?.data?.target_content,
            range: lastLog?.data?.range,
          },
        };
        setAILogs((prev: any) => [...prev, rewriteTip]);
      }
    }
  }, [aiLogs]);

  //切换当前操作
  const toggleHandle = (data: any) => {
    //更新当前的操作类型
    updateState({
      curOperationType: {
        type: data.type,
        data: data,
      },
    });

    //用户的默认文案
    let addObj = {
      key: nanoid(),
      type: 'userRecover',
      data: data.name,
    };
    setAILogs((prev: any) => [...prev, addObj]);
    //根据不同的操作类型 系统自动回复不同的文案
    if (data.systemRecover && data.systemRecover !== '') {
      let systemTxtRecover = {
        key: nanoid(),
        type: 'systemTxtRecover',
        spend: 15,
        // isTypewriter:false, //是否使用打字机效果
        data: [data.systemRecover],
      };
      setAILogs((prev: any) => [...prev, systemTxtRecover]);
    }
    //隐藏 - 文件上传框
    props.setShowUpload(false);
    //根据不同的操作类型 出现不同的操作框
    if (data.type === 'findInfo') {
      //查找参考资料
    } else if (data.type === 'uploadInfo') {
      //上传参考资料
      props.setShowUpload(true); //显示 - 文件上传框
    } else if (data.type === 'inspireIdeas') {
      //启发写作思路
    } else if (data.type === 'generateArticle') {
      //生成文章

      //选择篇数
      let selectNum = {
        key: nanoid(),
        type: 'selectNum',
        data: data,
      };
      setAILogs((prev: any) => [...prev, selectNum]);

      updateState({
        curOperationType: { type: 'input', data: null },
      });
    }
  };
  //暴露给父组件的引用
  useImperativeHandle(ref, () => ({
    toggleHandle,
  }));

  const addContentRich = (data: any) => {
    //延迟添加一个内容丰富提示框
    setTimeout(() => {
      let addObj2 = {
        key: nanoid(),
        type: 'contentRich',
        data: {
          ...data,
        },
      };
      setAILogs((prev: any) => [...prev, addObj2]);
    }, 1000);
  };

  //触发参考内容更新
  const triggerReference = (data: any) => {
    props.triggerReference(data);
  };
  //触发大纲主题更新
  const triggerArticleMain = (data: any) => {
    props.triggerArticleMain(data);
  };
  //文件的参考方向
  const handleFileSelect = async (index: any, data: any, type: string) => {
    let addObj = {
      key: nanoid(),
      type: 'userRecover',
      data: type,
    };
    setAILogs((prev: any) => [...prev, addObj]);
    console.log(index, data);
    let material_type = index === 2 ? '结构资料' : index === 3 ? '内容资料' : '';
    let body: any = {
      writing_session_id: writing_session_id,
      material_type: material_type,
    };
    let newFormData: any = new FormData();
    //将formObj的参数添加到newFormData里
    Object.keys(body).forEach((key) => {
      newFormData.append(key, body[key]);
    });
    newFormData.append('file', data?.originFileObj, data?.originFileObj?.name);
    updateState({
      robotLoading: true,
    });
    let res = await freeReference(newFormData);
    if (res.code === 0) {
      await triggerReference(index); //更新参考内容
      setTimeout(() => {
        updateState({
          robotLoading: false,
        });
        let add = {
          isUpload: true,
          material_id: res?.data?.material_id,
          material_type: index,
        };
        addContentRich(add);
      }, 500);
      setTimeout(() => {
        let systemTxtRecover = {
          key: nanoid(),
          type: 'systemTxtRecover',
          isTypewriter: false, //是否使用打字机效果
          data: [`小麦已将文件内容添加到${material_type}`],
        };
        setAILogs((prev: any) => [...prev, systemTxtRecover]);
      }, 2000);
      if (index === 2) {
        setTimeout(async () => {
          let systemTxtRecover2 = {
            key: nanoid(),
            type: 'systemTxtRecover',
            spend: 30,
            data: [`小麦正在更新大纲…`],
          };
          setAILogs((prev: any) => [...prev, systemTxtRecover2]);
          //手动 调用接口 更新大纲
          let res2 = await mainPointGenerate({ write_session_id: writing_session_id });
          if (res2.code === 0) {
            triggerArticleMain(2); //更新文章大纲
          }
        }, 2500);
      }
    } else {
      updateState({
        robotLoading: false,
      });
      message.open({
        type: 'error',
        content: res.msg,
      });
    }
  };

  //点击提供更多观点
  const handleThinkingMore = async (item: any, index: number) => {
    // console.log(item, index);
    updateState({
      robotLoading: true,
    });
    let body = {
      theme: item,
    };
    const res = await viewpoints(body);
    if (res.code === 0) {
      if (res?.data?.length > 0) {
        // 启发写作思路 返回的资料
        let keyId = nanoid();
        let addObj = {
          key: keyId,
          type: 'thinkingResult',
          data: {
            list: res?.data,
            keyword: item,
          },
        };
        // setAILogs((prev) => [...prev, addObj]);
        //将addObj加在index之前
        const newAILogs = [...aiLogs];
        newAILogs.splice(index, 0, addObj);
        // 更新状态以反映新的数组
        setAILogs(newAILogs);

        setTimeout(() => {
          //从newAILogs里根据key获取到新增的写作思路是容器里中的第几个thinkingResultBox
          let idx = newAILogs
            .filter((item: any) => item.type === 'thinkingResult')
            .findIndex((item: any) => item.key === keyId);
          scrollToEle('.thinkingResultBox', 30, idx < 0 ? 0 : idx);
        }, 1000);
      }
      updateState({
        robotLoading: false,
      });
    } else {
      updateState({
        robotLoading: false,
      });
      message.open({
        type: 'error',
        content: res.msg,
      });
    }
  };
  const handleGenerateSubmit = (data: number) => {
    props.generateSubmit(data);
    updateState({
      curOperationType: {
        type: 'input',
        data: null,
      },
    });
    let systemTxtRecover = {
      key: nanoid(),
      type: 'systemTxtRecover',
      spend: 15,
      isTypewriter: false, //是否使用打字机效果
      data: ['好的，小麦已经开始生成文章，请稍等...'],
    };
    setAILogs((prev: any) => [...prev, systemTxtRecover]);
  };

  const items = [
    {
      label: (
        <div>
          <span style={{ marginLeft: '5px' }}>
            <img className="yuanwenicon" src={yuanwen} height={15} width={15} />
            定位到原文
          </span>
        </div>
      ),
      key: '1',
    },
  ];
  //定位到原文
  const dropDownClick: (v: any, item: any) => void = (v, item) => {
    v.domEvent.stopPropagation();
    if (item?.data?.range) {
      updateState({
        curOperationType: {
          type: 'showLocation',
          data: item?.data?.range,
        },
      });
    }
  };
  //查看相关推荐
  const lookRecommend = async (data: any) => {
    updateState({
      robotLoading: true,
    });
    let query = data?.data.keyword;

    //将aiLogs里获取type=miniModelArticle 的data组合成一组
    const filteredDataArray = aiLogs
      .filter((item: any) => item.type === 'miniModelArticle')
      .map((item: any) => item.data)
      .flat();
    //匹配出当前相关推荐已显示的id 用于后台去重
    const ids = filteredDataArray
      .filter((item: any) => item.keyword === data.data.keyword)
      .map((item: any) => item.sentence_id);

    let res = await articleRecommend({ query, ids });
    if (res.code === 0) {
      updateState({
        robotLoading: false,
      });
      const articlesWithKeyword = res.data.articles.map((article: any) => ({
        ...article,
        query: query, //相关推荐的query为数组第一个的main_body
        keyword: data?.data.keyword,
      }));
      let miniModelArticle = {
        key: nanoid(),
        type: 'miniModelArticle',
        isTypewriter: true,
        data: articlesWithKeyword,
      };
      setAILogs((prev: any) => [...prev, miniModelArticle]);

      //小于5条表示后面没有数据了
      if (res.data.articles.length <= 4) {
        setTimeout(() => {
          //添加通用的系统文字回复类型
          let systemTxtRecover = {
            key: nanoid(),
            isTypewriter: false,
            type: 'systemTxtRecover',
            data: ['非常抱歉，没有更多结果可供显示，请尝试使用其他关键词。'],
          };
          setAILogs((prev: any) => [...prev, systemTxtRecover]);
        }, 500 + 800 * res?.data?.articles.length);
      } else {
        setTimeout(() => {
          let lookRecommend = {
            key: nanoid(),
            type: 'lookRecommend',
            data: data.data,
          };
          setAILogs((prev: any) => [...prev, lookRecommend]);
        }, 500 + 800 * res?.data?.articles.length);
      }
    } else {
      updateState({
        robotLoading: false,
      });
      message.error(res.msg);
    }
  };
  //踩的反馈提交
  const submitFeedbackCai = async (item: any, item2: any) => {
    let body = {
      query_string: item?.data?.query_string,
      query_result: item?.data?.query_result,
      source: '小模型',
      type: item?.data?.type,
      reason_ids: [item2.id],
    };
    let res = await search_feedback(body);
    if (res.code === 0) {
      let caiTxt = '收到您的反馈，我会总结经验，努力改进的。';
      let zancaiTip = {
        key: nanoid(),
        type: 'userZanCai',
        data: {
          type: item?.data?.type,
          reason: item2.name,
          target_content: item?.data?.sentence,
          range: null,
        },
      };

      setTimeout(() => {
        setAILogs((prev: any) => [...prev, zancaiTip]);
        updateState({
          robotLoading: false,
          curOperationType: {
            type: 'cancelZanCai',
            data: null,
          },
        });
      }, 500);

      setTimeout(() => {
        let systemTxtRecover = {
          key: nanoid(),
          type: 'systemTxtRecover',
          spend: 30,
          data: [caiTxt],
        };
        setAILogs((prev: any) => [...prev, systemTxtRecover]);
      }, 1000);
    } else {
      message.error(res.msg);
    }
  };

  return (
    <>
      <div className="commandList">
        <div className="commandList-bd">领导您好，我是您的写作实习生 - 小麦</div>
      </div>
      <div className="helpHandleBox">
        <div className="helpHandleTitle">请问需要什么帮助，小麦可以帮您：</div>
        <div className="helpHandleTagBox">
          {highClassHandle.map((item: any) => (
            <Button size="small" onClick={() => toggleHandle(item)} key={nanoid()}>
              {item.name}
            </Button>
          ))}
        </div>
      </div>
      {/* <UpdateMain></UpdateMain> */}
      {/* <ContentRich setAILogs={setAILogs}></ContentRich> */}
      {/* <ThinkingResult></ThinkingResult> */}
      {/* <AnalyzeResult/> */}
      {/* <div className='analyzeInfoBox'>
        <div className='analyzeInfo'>
          <div className='analyzeInfoTitle'>根据“党政府的新规学习手册”的分析结果如下：</div>
          <div className='analyzeInfoContent'>
          在文化传承发展座谈会上的讲话（2023年6月2日）习近平2023年6月2日，中共中央军委主席习近平在北京出席文化传承发展座谈会并发表重要讲话。
          </div>
          
        </div>
        <div className='analyzeInfoHandle'>
          <span className='analyzeInfoIcon'>
            <FileUnknownOutlined/>
          </span>
        </div>
      </div> */}
      {/* <div className='selectArticleNumBox'>
        <div className='selectArticleNumTitle'>请告诉小麦您想要生成的文章篇数</div>
        <div className='selectArticleNumList'>
          <div className='selectArticleNumList-hd'>

          </div>
          <div className='selectArticleNumList-bd'>* 生成时间较长，文章质量较高</div>
          
        </div>
        <div className='selectArticleNumBtnBox'>
          <Button type="primary">确定</Button>
        </div>
        
      </div> */}

      {/* <SelectArticleNum></SelectArticleNum> */}

      {aiLogs.length > 0 &&
        aiLogs.map((item: AILogsCon, index: number) => {
          if (item.type === 'userInput') {
            // 用户的命令
            return (
              <div key={item.key} className="commandList userCommand">
                <div
                  className="commandList-bd"
                  dangerouslySetInnerHTML={{ __html: replaceN(item.data) }}
                ></div>
              </div>
            );
          } else if (item.type === 'userRecover') {
            //用户的默认文案
            return (
              <div key={item.key} className="commandList userCommand">
                <div
                  className="commandList-bd"
                  dangerouslySetInnerHTML={{ __html: replaceN(item.data) }}
                ></div>
              </div>
            );
          } else if (item.type === 'systemTxtRecover') {
            // 系统的文字回应
            return (
              <UserRecover
                key={item.key}
                data={item.data}
                scrollToBottom={scrollToBottom}
                spend={item.spend}
                isTypewriter={item.isTypewriter}
              ></UserRecover>
            );
          } else if (item.type === 'scoreTip') {
            // 评分的回应
            return (
              <div className="commandList" key={item.key}>
                <Typewriter className="commandList-bd" text={item.data} />
              </div>
            );
          } else if (item.type === 'userZanCai') {
            //赞和踩的回应
            return (
              <Dropdown
                disabled={!item?.data?.range}
                key={item.key}
                menu={{ items, onClick: (v) => dropDownClick(v, item) }}
                trigger={['contextMenu']}
              >
                <div className="commandListBox userType">
                  <div className="commandList userCommand">
                    <div className="commandList-bd">{item?.data?.reason}</div>
                    {/* <Typewriter className="commandList-bd"  text={item?.data?.reason} /> */}
                  </div>
                  <div className="commandZanCaiBox">
                    <span className="commandZanCai-hd">
                      {item.data.type === 1 ? (
                        <LikeFilled style={{ color: '#60D9A4' }} />
                      ) : (
                        <DislikeFilled style={{ color: '#F57070' }} />
                      )}
                    </span>
                    <div className="commandZanCai-bd">
                      <span>{item?.data?.target_content}</span>
                    </div>
                  </div>
                </div>
              </Dropdown>
            );
          } else if (item.type === 'userFanGai') {
            //用户的仿写重写文案
            return (
              <Dropdown
                key={item.key}
                menu={{ items, onClick: (v) => dropDownClick(v, item) }}
                trigger={['contextMenu']}
              >
                <div key={item.key} className="commandListBox userType">
                  <div className="commandList userCommand">
                    <div className="commandList-bd">{item?.data?.reason}</div>
                  </div>
                  <div className="commandZanCaiBox">
                    <div className="commandZanCai-bd">
                      <span>{item?.data?.text}</span>
                    </div>
                  </div>
                </div>
              </Dropdown>
            );
          } else if (item.type === 'rewriteTip') {
            //提示重写仿写
            return (
              <div className="commandListBox" key={item.key}>
                <div className="commandList">
                  <div className="commandList-bd">
                    {item?.data?.reason}
                    {/* <Typewriter className="commandList-bd" text={item?.data?.reason} /> */}
                    <div className="fangxieBtnBox">
                      {item?.data.type === 1 ? (
                        <Button type="primary" onClick={() => handleFanGai(1, item.data)}>
                          仿写
                        </Button>
                      ) : (
                        <Button type="primary" onClick={() => handleFanGai(2, item.data)}>
                          重写
                        </Button>
                      )}
                    </div>
                  </div>
                </div>
              </div>
            );
          } else if (item.type === 'lookSource') {
            //聊天 查看来源
            return (
              <ArticleSource
                key={item.key}
                data={item.data}
                scrollToBottom={scrollToBottom}
              ></ArticleSource>
            );
          } else if (item.type === 'miniModelArticle') {
            // 小模型训练文章
            return (
              <MiniModelArticle
                key={item.key}
                setAILogs={setAILogs}
                updateState={updateState}
                data={item.data}
                scrollToBottom={scrollToBottom}
              ></MiniModelArticle>
            );
          } else if (item.type === 'feedbackReasons') {
            // 是否查看更多结果
            return (
              <div className="feedbackReasonsWrap" key={item.key}>
                <div className="feedbackReasonsBox">
                  <div className="feedbackReasonsTitle">
                    很抱歉，小麦的的回答没有让您满意，请说明原因：
                  </div>
                  <div className="feedbackReasonsListBox">
                    {feedbackReasons &&
                      feedbackReasons.length > 0 &&
                      feedbackReasons.map((item2: any) => {
                        return (
                          <div
                            key={item2.id}
                            className="feedbackReasonsList"
                            onClick={() => submitFeedbackCai(item, item2)}
                          >
                            {item2.name}
                          </div>
                        );
                      })}
                  </div>
                  <div className="feedbackReasonsFoot">
                    如有其他问题描述及建议请在下方输入框输入
                  </div>
                </div>
              </div>
            );
          } else if (item.type === 'lookRecommend') {
            // 是否查看更多结果
            return (
              <div className="recommendBox" key={item.key}>
                <span className="recommend-hd">是否查看更多结果</span>
                <span className="recommend-bd">
                  <Button
                    type="primary"
                    onClick={() => {
                      lookRecommend(item);
                    }}
                  >
                    好的
                  </Button>
                </span>
              </div>
            );
          } else if (item.type === 'rewriteResult') {
            //重写仿写后台返回的结果
            return (
              <div key={item.key}>
                <RewriteResult
                  data={item.data}
                  setAILogs={setAILogs}
                  updateState={updateState}
                  scrollToBottom={scrollToBottom}
                ></RewriteResult>
              </div>
            );
          } else if (item.type === 'robotLoading') {
            //机器人loading
            return (
              <div className="commandList" key={item.key}>
                <div className="commandList-bd">
                  <img className="avatar" src={POINTLOADING} height={14} width={21} />
                </div>
              </div>
            );
          } else if (item.type === 'findProfileResult') {
            //返回的 参考资料
            return (
              <MarkerProfile
                key={item.key}
                data={item.data}
                scrollToBottom={scrollToBottom}
                onComplete={addContentRich}
                triggerReference={triggerReference}
                triggerArticleMain={triggerArticleMain}
                setAILogs={setAILogs}
              ></MarkerProfile>
            );
          } else if (item.type === 'contentRich') {
            //内容丰富提示框
            return (
              <ContentRich
                key={item.key}
                data={item.data}
                scrollToBottom={scrollToBottom}
                setAILogs={setAILogs}
                toggleHandle={toggleHandle}
                highClassHandle={highClassHandle}
              ></ContentRich>
            );
          } else if (item.type === 'thinkingResult') {
            //思路观点结果框
            return (
              <ThinkingResult
                key={item.key}
                data={item.data}
                scrollToBottom={scrollToBottom}
                triggerReference={triggerReference}
                triggerArticleMain={triggerArticleMain}
                setAILogs={setAILogs}
              ></ThinkingResult>
            );
          } else if (item.type === 'thinkingMore') {
            //更多思路和观点
            return (
              <div className="thinkingMoreBox" key={item.key}>
                <div className="thinkingMore-hd">需要小麦提供更多观点吗？</div>
                <div
                  className="thinkingMore-bd"
                  onClick={() => {
                    handleThinkingMore(item.data, index);
                  }}
                >
                  提供更多
                </div>
              </div>
            );
          } else if (item.type === 'uploadResult') {
            //上传结果
            return (
              <div className="uploadFileInfoBox" key={item.key}>
                <div className="uploadFileInfo">
                  {item?.data?.originFileObj && (
                    <div className="uploadFileInfo-hd">
                      {item?.data?.originFileObj.accept === 'docx' ||
                      item?.data?.originFileObj?.accept === 'doc' ? (
                        <FileWordOutlined />
                      ) : item?.data?.originFileObj?.accept === 'txt' ? (
                        <FileTextOutlined />
                      ) : item?.data?.originFileObj?.accept === 'pdf' ? (
                        <FilePdfOutlined />
                      ) : (
                        <FileUnknownOutlined />
                      )}
                    </div>
                  )}
                  <div className="uploadFileInfo-bd">{item.data.name}</div>
                </div>
              </div>
            );
          } else if (item.type === 'fileSelect') {
            //上传结果选择参考方向
            return (
              <div className="fileSelectBox" key={item.key}>
                <div className="fileSelect">
                  <div className="fileSelectTitle">请选择需要参考的方向：</div>
                  <div className="fileSelectList">
                    <span
                      onClick={() => {
                        handleFileSelect(2, item.data, '参考格式');
                      }}
                    >
                      参考格式
                    </span>
                    <span
                      onClick={() => {
                        handleFileSelect(3, item.data, '参考内容');
                      }}
                    >
                      参考内容
                    </span>
                  </div>
                </div>
              </div>
            );
          } else if (item.type === 'analyzeResult') {
            //分析结果
            return (
              <AnalyzeResult
                key={item.key}
                data={item.data}
                scrollToBottom={scrollToBottom}
                triggerReference={triggerReference}
                triggerArticleMain={triggerArticleMain}
                setAILogs={setAILogs}
              ></AnalyzeResult>
            );
          } else if (item.type === 'selectNum') {
            //选择篇数
            return (
              <SelectArticleNum
                key={item.key}
                generateSubmit={handleGenerateSubmit}
                setAILogs={setAILogs}
              />
            );
          } else if (item.type === 'updateMain') {
            //更新大纲or 不更新大纲
            return (
              <UpdateMain
                key={item.key}
                scrollToBottom={scrollToBottom}
                writing_session_id={writing_session_id}
                triggerReference={triggerReference}
                triggerArticleMain={triggerArticleMain}
                setAILogs={setAILogs}
              />
            );
          } else {
            return '<></>';
          }
        })}
    </>
  );
});
export default connect(({ highClassWrite }) => ({ highClassWrite }), null, null, {
  forwardRef: true,
})(AiCommandLogs);
